home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / assignShadingGroups.mel < prev    next >
Encoding:
Text File  |  2003-07-17  |  2.9 KB  |  86 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //
  18. //  Alias|Wavefront Script File
  19. //  MODIFY THIS AT YOUR OWN RISK
  20. //
  21. //  Creation Date:  12 Dec 1996
  22. //  Author:         spam
  23. //
  24. //  Description:
  25. //      Assign the nodes in thisNode[] to the second node.
  26. //
  27.  
  28. global proc assignShadingGroups(string $thisNode[], string $toThisNode)
  29. //
  30. //  Procedure Name:
  31. //      assignShadingGroups
  32. //
  33. //  Description:
  34. //      Implements a render assign.  The names in the array should all be 
  35. //        names of renderable geometry.  If $toThisNode is a shadingEngine (SE),
  36. //        each array element is added as a member of it.  If $toThisNode isn't
  37. //        an SE, the optionVar "assignPref" is checked.  If True, a new SE is
  38. //        created, each array element is added as a member, and $toThisNode is
  39. //        attached to the surfaceshader attr of the new SE.
  40. //        
  41. //  Input Arguments:
  42. //        string $thisNode[] - array of nodes to assign
  43. //        string $toThisNode - single node name to assign *to*
  44. //
  45. //  Return Value:
  46. //      None.
  47. //
  48. {
  49.     string $toType = `nodeType $toThisNode`;
  50.     string $SEname = $toThisNode;
  51.     string $cmd;
  52.     string $exitVal = "OK";
  53.  
  54.     if($toType != "shadingEngine") {
  55.         $exitVal = `confirmDialog -title "WARNING" -message 
  56.                          ($toThisNode + " is not a Shading Group.  Geometry can only be assigned to"
  57.                           + "\nShading Groups.  Press OK to create a new Shading Group that shades" +
  58.                           "\nwith " + $toThisNode + " and perform the assignment, or Cancel to do nothing.")
  59.                          -button "OK" -button "Cancel"
  60.                          -defaultButton "OK" -cancelButton "Cancel"
  61.                          -dismissString "Cancel"`;
  62.  
  63.         if ($exitVal == "OK") {
  64.  
  65.             $cmd = "sets -renderable true -noSurfaceShader true -name " + $toThisNode + "SG -empty";
  66.             $SEname = `evalEcho $cmd`;
  67.         
  68.             $cmd = "defaultNavigation -f true -connectToExisting -source " + $toThisNode + " -destination " + $SEname;
  69.             evalEcho $cmd;
  70.         }
  71.     }
  72.     
  73.     if ($exitVal == "OK") {
  74.         $cmd = "sets -e -forceElement " + $SEname;
  75.  
  76.         int $i;
  77.         int $numNodes = `size $thisNode`;
  78.         
  79.         for ($i = 0; $i < $numNodes; $i++) {
  80.             $cmd += " " + $thisNode[$i];
  81.         }
  82.             
  83.         evalEcho $cmd;
  84.     }
  85. }
  86.